xlv.obj.process={
	extend:function(){
	},
	implement:function(){
	},
	create:function(tag){
		var div=document.createElement((tag||'div'));
		div.setAttribute('xlvobject','xlv.obj.process');
		return div;			
	},
	properties:{
		title:'',
		imgLayout:'left',
		srcImg:null,
		srcImgHover:null,
		srcImgClick:null,
		srcImgDisabled:null,
		options:null,
		enabled:true,
		interval:0
	},
	method:{
		construct:function(){
			Element.addClassName(this,'class_process');
			var v=this.$V;
			v.title=xlv.util.findDirectChild(this,{id:'xlvid_process_title'});
			if(!v.title){
				this.appendChild(v.title=document.createElement('span'));
				v.title.setAttribute('id','xlvid_process_title');
			}
			xlv.util.setElementValue(v.title,this.$P.title);
			v.title.style.padding='0px 0px 0px 0px';
			this.styleForId(v.title,v.title.id);
			if(this.$P.srcImg){
				var img=new Image();
				img.src=this.$P.srcImg;
				var dim=Element.getDimensions(v.title);
				setTimeout(function(){
						if(img.width!=0)this._load();
						else this.addEventHandler('load','_load',img);
					}.bind(this),(dim.width==0)?300:1);
			}
		},
		initial:function(){
			this.addEventHandler('click','_click');
			this.addEventHandler('mouseover','_mouseover');
			this.addEventHandler('mouseout','_mouseout');
			this.enabled(this.$P.enabled);
			this.resetInterval();
		},
		dispose:function(){
			this.clearInterval();
		},
		styleForId:function(title,id){
		},
		resetInterval:function(){
			this.clearInterval();
			if(this.$P.interval>0 && xlv.util.isDescendantOf(this,document.body))
				this.$V._interval=setInterval(function(){this._interval();}.bind(this),this.$P.interval);
		},
		clearInterval:function(){
			if(this.$V._interval)clearInterval(this.$V._interval);
			this.$V._interval=null;
		},
		enabled:function(enabled){
			if(enabled===false)	Element.addClassName(this,'disabled');
			else Element.removeClassName(this,'disabled');
		},
		setTitle:function(title){
			var v=this.$V;
			xlv.util.setElementValue(v.title,title);
			if(this.$P.srcImg)this._load();
		},
		getTitle:function(){
			return xlv.util.getElementValue(this.$V.title);
		},
		_load:function(event){
			var v=this.$V;
			var img=new Image();
			img.src=this.$P.srcImg;
			var dim=Element.getDimensions(v.title);
			var background='URL('+this.$P.srcImg+')'; 
			var padding='';
			var halfw=Math.ceil((img.width-dim.width)/2);
			var halfh=Math.ceil((img.height-dim.height)/2);
			var w,h;
			switch(this.$P.imgLayout){
			case 'center' :
				w=((halfw>0)?halfw:0)+'px';
				h=((halfh>0)?halfh:0)+'px';
				padding=h+' '+w+' '+h+' '+w;
				background+=' center no-repeat';
				break;
			case 'left':
				w=img.width+'px';
				h=((halfh>0)?halfh:0)+'px';
				padding=h+' 0px '+h+' '+w;
				background+=' left center no-repeat ';
				break;
			case 'top':
				w=((halfw>0)?halfw:0)+'px';
				h=img.height+'px';
				padding=h+' '+w+' 0px '+w;
				background+=' top center no-repeat ';
				break;
			case 'right':
				w=img.width+'px';
				h=((halfh>0)?halfh:0)+'px';
				padding=h+' '+w+' '+h+' 0px';
				background+=' right center no-repeat ';
				break;
			case 'bottom':
				w=((halfw>0)?halfw:0)+'px';
				h=img.height+'px';
				padding='0px '+w+' '+h+' '+w;
				background+=' bottom center no-repeat ';
				break;
			}
			v.title.style.background=background;
			v.title.style.padding=padding;
		},
		_mouseover:function(event){
			if(Element.hasClassName(this,'disabled')){
				if(this.$P.srcImgDisabled)this.$V.title.style.backgroundImage='URL('+this.$P.srcImgDisabled+')';
				else if(this.$P.srcImg) this.$V.title.style.backgroundImage='URL('+this.$P.srcImg+')';
			}else if(this.$P.srcImgHover)this.$V.title.style.backgroundImage='URL('+this.$P.srcImgHover+')';
		},
		_mouseout:function(event){
			if(Element.hasClassName(this,'disabled')&&this.$P.srcImgDisabled)this.$V.title.style.backgroundImage='URL('+this.$P.srcImgDisabled+')';
			else if(this.$P.srcImg) this.$V.title.style.backgroundImage='URL('+this.$P.srcImg+')';
		},
		_click:function(event){
			if(event)this.resetInterval();
			if(Element.hasClassName(this,'disabled'))return;
			if(this.$P.srcImgClick) this.$V.title.style.backgroundImage='URL('+this.$P.srcImgClick+')';
			setTimeout(function(){this.process();}.bind(this),1);
			if(event)event.stop();
		},
		_interval:function(){
			this._click(null);
		},
		process:function(options){
			options=(options||this.$P.options);
			if(!options) return;
			if(Object.isFunction(options))options();
			else eval(options);
		}
	}
};
